/*!
 * This file contains template Singleton class
 * 
 * Copyright (c) 2011 by Svyatoslav Zaytsev / organization here>
 */
#pragma once


/*!
	* \brief
	* Write brief comment for Singleton here.
	* 
	* \param T
	* Description of parameter T.
	* 
	* Write detailed description for Singleton here.
	* 
	* \remarks
	* Write remarks for Singleton here.
	* 
	* \see
	* Separate items with the '|' character.
	*/
template<class T> class Singleton
{
public:
	static T*			GetInstance()	
	{	
		return ManageInstance();
	}

	static void			ReleaseInstance()
	{
		ManageInstance( true );
	}

protected:
	static T* ManageInstance( bool destroy = false )
	{
		static T* m_sInstance; //

		if( destroy )
		{
				delete m_sInstance ;
		}
		else
		{
			if( !m_sInstance )
			{
				m_sInstance = new T();
			}
		}

		return m_sInstance;
	}

	virtual ~Singleton() {};
	Singleton() {};
};